package chapter4.No4_2_使用ReentrantReadWriteLock类.demo1;

import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * Created by Administrator on 2016/11/24.
 */
public class Service {
    ReentrantReadWriteLock lock = new ReentrantReadWriteLock();

    public void read() {
        lock.readLock().lock();
        try {
            System.out.println(Thread.currentThread().getName()+" 进入锁的时间："+System.currentTimeMillis());
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        lock.readLock().unlock();
    }
}
